Skip to content

fix(deps): auto-install missing dependencies on first run#72

Merged
avifenesh merged 4 commits intomainfrom
fix/plugin-cache-deps-66
Feb 25, 2026
Merged

fix(deps): auto-install missing dependencies on first run#72
avifenesh merged 4 commits intomainfrom
fix/plugin-cache-deps-66

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Auto-install playwright and Chromium browser on first browser operation when the plugin cache is missing dependencies
  • Add missing_dependency error classification with actionable install instructions as fallback
  • Move playwright from peerDependencies to dependencies so npm install actually installs it
  • Add WEB_CTL_SKIP_AUTO_INSTALL=1 env var to disable auto-install in CI/sandboxed environments

Implementation

  • New scripts/ensure-deps.js - dependency checker with lockfile coordination (Atomics.wait for CPU-friendly sync sleep, PID-based stale lock detection)
  • scripts/browser-launcher.js - calls ensurePlaywright() before require('playwright') in launchBrowser() and canLaunchHeaded()
  • scripts/web-ctl.js - missing_dependency classification added before element_not_found to prevent substring match collision

Test plan

  • 19 new tests in tests/ensure-deps.test.js (happy path, caching, subprocess failure paths, stale lock detection)
  • 3 new tests in tests/web-ctl-actions.test.js (missing_dependency classification)
  • Fixed 2 pre-existing platform-specific test failures (canLaunchHeaded on Windows)
  • 530/530 tests passing, 0 failures

Closes #66

Add ensure-deps.js that detects missing playwright dependency and
auto-installs it with lockfile-based coordination between processes.
Call ensurePlaywright() in browser-launcher before requiring playwright.

Move playwright from peerDependencies to dependencies in package.json
so npm install resolves it automatically.

Add missing_dependency error classification in web-ctl.js classifyError
before the element_not_found branch to prevent 'Cannot find module'
from being misclassified as an element not found error.

Closes #66
- Replace grep-based source contract tests with behavioral subprocess tests
- Fix canLaunchHeaded tests that assumed Linux-only behavior (Windows can
  launch headed browsers without X11/DISPLAY)
- Remove unnecessary defensive comment about shell injection in ensure-deps
- Replace CPU-spinning busy-wait loop with Atomics.wait (yields CPU)
- Fix acquireLock to return false when lock disappears (was unreachable)
- Add PID validation for NaN/invalid values in lockfile
- Add subprocess tests for npm install failure, chromium install failure,
  lockfile cleanup after failure, and stale lock detection
- README: replace manual playwright/chromium install with auto-install note
- README: update Requirements section
- CHANGELOG: add entry for auto-install feature
- web-auth SKILL.md: update error handling to mention auto-install
@avifenesh avifenesh merged commit 0d3a728 into main Feb 25, 2026
2 of 4 checks passed
@avifenesh avifenesh deleted the fix/plugin-cache-deps-66 branch February 25, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin cache missing dependencies on first run

1 participant